package com.bf.electroplating.job;

import com.bf.electroplating.service.IRainfallSuspectedDischargeSyncService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * 雨排口疑似偷排记录同步定时任务
 * 
 * @author system
 * @since 2025-01-11
 */
@Slf4j
@Component
public class RainfallSuspectedDischargeSyncJob {

    @Autowired
    private IRainfallSuspectedDischargeSyncService rainfallSuspectedDischargeSyncService;

    /**
     * 每天凌晨3点同步一次疑似偷排记录
     * 定时任务：每天凌晨3点执行
     */
    @Scheduled(cron = "0 0 3 * * ?")
    public void syncSuspectedDischargeDataDaily() {
        try {
            log.info("开始执行雨排口疑似偷排记录同步定时任务");
            rainfallSuspectedDischargeSyncService.syncAllSuspectedDischargeData();
            log.info("雨排口疑似偷排记录同步定时任务执行完成");
        } catch (Exception e) {
            log.error("雨排口疑似偷排记录同步定时任务执行异常", e);
        }
    }

    /**
     * 每周二凌晨4点执行一次全量同步
     * 定时任务：每周二凌晨4点执行
     */
    @Scheduled(cron = "0 0 4 ? * TUE")
    public void syncSuspectedDischargeDataWeekly() {
        try {
            log.info("开始执行雨排口疑似偷排记录每周全量同步任务");
            rainfallSuspectedDischargeSyncService.syncAllSuspectedDischargeData();
            log.info("雨排口疑似偷排记录每周全量同步任务执行完成");
        } catch (Exception e) {
            log.error("雨排口疑似偷排记录每周全量同步任务执行异常", e);
        }
    }
}
